/**
 * 
 */
package com.ihg.hiex.admin.dao.session;

import java.util.Date;
import java.util.List;
import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.SessionNotification;

/**
 * 
 * @author houtao
 *        
 */
@Dao("hibernate")
public interface SessionNotificationDao {
    
    /**
     * @param code
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND code = :code AND sent = :sent")
    public List<SessionNotification> list(@Variable("code") String code, @Variable("sent") boolean sent);
    
    /**
     * @param code
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND code IN (:codes) AND sent = :sent")
    public List<SessionNotification> list(@Variable("codes") List<String> code, @Variable("sent") boolean sent);
    
    /**
     * @param code
     * @param occurTime
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND code IN (:codes) AND occurTime <= :occurTime AND sent = :sent")
    public List<SessionNotification> list(@Variable("codes") List<String> code, @Variable("occurTime") Date occurTime, @Variable("sent") boolean sent);

    /**
     * 
     * @param session
     * @param code
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND session = :session AND code = :code AND sent = :sent")
    public List<SessionNotification> list(@Variable("session") Session session, @Variable("code") String code, @Variable("sent") boolean sent);

    /**
     * 
     * @param code
     * @param session
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND code = :code AND session = :session AND sent = :sent")
    public SessionNotification load(@Variable("code") String code, @Variable("session") Session session, @Variable("sent") boolean sent);
    
    /**
     * 
     * @param session
     * @param code
     * @param occurTime
     * @param sent
     * @return
     */
    @Query("FROM SessionNotification WHERE disabled = false AND session = :session AND code = :code AND occurTime <= :occurTime AND sent = :sent")
    public SessionNotification load(@Variable("session") Session session, @Variable("code") String code, @Variable("occurTime") Date occurTime, @Variable("sent") boolean sent);
    
} 
